#include "../esyio.h"

typedef struct {
    int num;  
    int den; 
} Fraction;


int gcd(int m, int n) {
    if (m % n == 0) {
        return n;
    }
    return  gcd(n,m%n);
}


void simplify(Fraction *frac) {
    int com = gcd(frac->num, frac->den);
    frac->num /= com;
    frac->den /= com;
}

Fraction add(Fraction frac1, Fraction frac2) {
    Fraction result;
    int common = gcd(frac1.den, frac2.den);
    result.den = frac1.den * frac2.den / common;
    result.num = frac1.num* (frac2.den / common) + frac2.num * (frac1.den / common);
    simplify(&result);
    return result;
}


Fraction mul(Fraction frac1, Fraction frac2) {
    Fraction result;
    result.den = frac1.den * frac2.den;
    result.num = frac1.num * frac2.num ;
    simplify(&result);
    return result;
}

int main() {(()())
    Fraction result = add((Fraction){1,3},(Fraction){1,2});
    PrintInt(result.num);
    PrintInt(result.den);
    return 0;
}
